/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.game.math.view.action;

import java.awt.event.ActionEvent;
import javax.swing.JOptionPane;
import java.awt.Component;
import org.game.math.view.config.Configure;

/**
 *
 * @author nmduc
 */
class MulTableAction(name:String, configure:Configure) extends AbstractToggleAction(name, configure) {

  def this(configure:Configure) {
    this(AbstractToggleAction.resourceBundle.getString("mulTable.menu.name"), configure);
    this.setSelected(configure.isChosenMultiTable());
  }

  override def actionPerformed(ae:ActionEvent):Unit = {
    val configure:Configure = Configure.getInstance();
    var multNumber:Int = configure.getChosenMultiNumber();
    if (this.isSelected()) {
      val multNumberTemp:String = JOptionPane.showInputDialog(ae.getSource().asInstanceOf[Component], "Ban muon lam bang cuu chuong may ?",
                                                              "Chon bang cuu chuong", JOptionPane.QUESTION_MESSAGE);
      multNumber = multNumberTemp.toInt;
    }
    configure.setChosenMultiTable(this.isSelected, multNumber);
  }
}
